Skip to content

ref: route all SDK diagnostics through debugLogger - #2631

Merged
Abhijeet Prasad (AbhiPrasad) merged 4 commits into
mainfrom
refactor/sdk-debug-logger
Oct 19, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 4 commits into
mainfrom
refactor/sdk-debug-logger

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Was looking at adding console.log instrumentation and figured we need to do this first. But open to other ideas.

AI Summary

Routes the SDK's remaining console.* diagnostics through debugLogger. Adds debugLogger.notice for user-facing messages that should stay visible by default.

debugLogger.warn("...");         // hidden unless a level is configured
debugLogger.notice.warn("...");  // shown by default
level configured?
  ├─ false      → silent
  ├─ "<level>"  → filter by level (applies to notice too)
  └─ unset      → notice.* prints as "warn", everything else silent
Method Used for
notice.* wrapper "Not wrapping" warnings, late configureInstrumentation, span customizer failure, dev server errors, publish() warnings, scorer/vitest warnings, auto-instrumentation transform failures
warn / error / debug internal swallowed errors (stream patcher, plugins, telemetry, disk cache), auto-instrumentation status

Behavior changes

Before After
Internal handler errors always printed Opt-in via BRAINTRUST_DEBUG_LOG_LEVEL / debugLogLevel
DEBUG='@braintrust*' showed auto-instrumentation status BRAINTRUST_DEBUG_LOG_LEVEL=debug
[braintrust] [Braintrust] ... Duplicate prefixes removed

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T19:52:06.068239Z 6815ef2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) changed the title refactor: route SDK diagnostics through debugLogger ref: route all SDK diagnostics through debugLogger Oct 16, 2026
Notice warnings and errors print at warn when no debug log level is
configured, respect an explicit level, and are silenced by
debugLogLevel: false. Use it for diagnostics that were always shown
before routing through debugLogger, only mark the span customizer
failure as logged once it is emitted, and drop duplicate Braintrust
prefixes from logger messages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40d8ea4827

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread js/src/debug-logger.ts
iso.getEnv("BRAINTRUST_DEBUG_LOG_LEVEL") ??
// Loader and bundler diagnostics can run before platform initialization.
(typeof process !== "undefined"
? process.env.BRAINTRUST_DEBUG_LOG_LEVEL

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard the process.env fallback

In browser or edge runtimes that expose a partial process shim without process.env, this fallback throws while evaluating process.env.BRAINTRUST_DEBUG_LOG_LEVEL. browser/config.ts explicitly supports this environment by having iso.getEnv return undefined when process.env is absent, but the new fallback defeats that guard; because browser initialization constructs BraintrustState, which calls getEnvDebugLogLevel, importing the SDK can now fail before use. Check that process.env exists before dereferencing it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6815ef2: the fallback now checks typeof process.env !== "undefined" (matching browser/config.ts), with a test for a process shim without env.

@lforst

Copy link
Copy Markdown
Member

cool!

Browser and edge runtimes can expose a process shim without env.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit ed651b8 into main Oct 19, 2026
57 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the refactor/sdk-debug-logger branch October 19, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants